/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2019-06-26 17:14:13
 * @Description: 首页-控制台-我的添加
 */
import { observable, action } from "mobx";
import resource from "@/utils/resource";
import API from "@/utils/api";

class MyAdditionStore {
    @observable topData = [];
    @observable listData = [];
    @observable currentPage = 1;

    @action.bound
    getTopData() {
        resource.get(API.homeMyAdditionTop).then(topData => {
            this.topData = topData;
        });
    }

    @action.bound
    getListData() {
        resource
            .get(API.homeMyAdditionLists, {
                page: this.currentPage
            })
            .then(res => {
                this.listData = res;
            });
    }

    @action.bound
    changePage(newPage) {
        this.currentPage = newPage;
        this.getListData();
    }
}

export default new MyAdditionStore();
